<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>宠物列表</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#" th:text="|欢迎${session.user.username}登录宠物管理系统|"></a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Dashboard</a></li>
                    <li><a href="#">Settings</a></li>
                    <li><a href="#">Profile</a></li>
                    <li><a href="#">Help</a></li>
                </ul>
                <form class="navbar-form navbar-right">
                    <input type="text" class="form-control" placeholder="Search...">
                </form>
            </div>
        </div>
    </nav>
    <div class="container-fluid" >
        <div class="row" style="margin-top: 40px;">
            <div class="col-sm-2 sidebar" style="background: azure;height: 600px">
                <ul class="nav nav-sidebar" style="font-size: 20px;margin-top: 30px">
                    <li><a href="#">宠物管理</a></li>
                    <li><a href="#">宠物类型管理</a></li>
                    <li><a href="#">用户管理</a></li>
                    <li><a href="#">订单管理</a></li>
                </ul>
            </div>
            <div class="col-sm-10 main">
                <h1 class="page-header">宠物列表</h1>
                <div class="table-responsive">
                    <a href="/addPet.html" style="font-size: 20px">添加宠物</a>
                    <table class="table table-striped table-bordered table-hover table-condensed">
                        <tr>
                            <th>编号</th><th>昵称</th><th>性别</th><th>年龄</th><th>颜色</th><th>价格</th><th>图片</th><th>类型</th><th>主人</th><th>操作</th>
                        </tr>
                        <tr th:each="pet : ${page.data}">
                            <td th:text="${pet.id}"></td>
                            <td th:text="${pet.name}"></td>
                            <td th:text="${pet.gender}"></td>
                            <td th:text="${pet.age}"></td>
                            <td th:text="${pet.color}"></td>
                            <td th:text="${pet.price}"></td>
                            <td><img th:src="@{|http://localhost:8080/pet-images/${pet.image}|}" style="width: 40px;height: 40px;border-radius: 50%"> </td>
                            <td th:text="${pet.typeId}"></td>
                            <td th:text="${pet.userId}"></td>
                            <td>
                                <a th:href="@{|/findPet?id=${pet.id}|}">更新</a> &nbsp;
                                <a th:onclick="deletePet([[${pet.id}]])">删除</a>
                            </td>
                        </tr>
                    </table>
                    <script>
                        function deletePet(id){
                            if(confirm("是否确定删除?")){
                                location.href = "/removePet?id=" + id;
                            }
                        }
                    </script>
                    <nav aria-label="Page navigation">
                        <ul class="pagination">
                            <li th:if="${page.current > 1}">
                                <a th:href="@{|/findPetsPage?current=${page.current - 1}|}" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li th:unless="${page.current > 1}" class="disabled">
                                <a aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li th:each="i : ${#numbers.sequence(1,page.pageCount)}" th:class="${i==page.current?'active':''}">
                                <a th:href="@{|/findPetsPage?current=${i}|}" th:text="${i}">1</a>
                            </li>
                            <li th:if="${page.current < page.pageCount}">
                                <a th:href="@{|/findPetsPage?current=${page.current + 1}|}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                            <li th:unless="${page.current < page.pageCount}" class="disabled">
                                <a aria-label="Previous">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </ul>
                    </nav>

                </div>
            </div>
        </div>
    </div>
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>

</body>
</html>
